<script src="<?=gurl('js');?>/plugin.js"></script>
<script language="javascript">
//动态编辑选项名称
var jsopname = "";
function aj_editing_options() {
	
	if($("#opname").val() == "") {
		$(".opcurrent > a:first").html(" ... ");
		return;
	} else if($("#opname").val().length == 1) {
		var pattern = /\w/;
		if(pattern.test($("#opname").val())) {
			$(".opcurrent > a:first").html($("#opname").val() + "...");
			return;
		}
		
	} /*else if(fucCheckLength($("#opname").val()) > 10){
		alert("选项名称长度超过限制");
		return;
	}*/
	
	//验证字符
	var pattern = /^[ \da-zA-Z\u0391-\uFFE5]{1,}$/;
	if(!pattern.test($("#opname").val())) {
		//alert("请输入字母、中文或数字");
		return;
	} else {
		$(".opcurrent > a:first").html($("#opname").val());
	}
	//$("#jsUserName").val($("#opname").val());
}
$(function (){
	if($.browser.msie){
	  $("#opname").get(0).onpropertychange = aj_editing_options; 	
	} else {
		var intervalName; // 定时器句柄
		$("#opname").get(0).addEventListener("input",aj_editing_options,false);
		// 获得焦点时，启动定时器
		$("#opname").focus(function(){
		intervalName = setInterval(handle,1000);
		});
		// 失去焦点时，清除定时器
		$("#opname").blur(function()
		{
		clearInterval(intervalName);
		}); 
	}
});

function handle(){
 if($(".opcurrent > a").html() != jsopname){
  jsopname = $(".opcurrent > a").html();
 }
}
</script>
<div class="w660">
		<? if($isowner && count($oplugins) == 0):?>
		<ul id="optiontips" class="listFans" style="margin:40px 0 0 12px">
			<li>*编辑选项在<?=$currentoption['opname'];?>下面</li>
			<li>*添加新选项在站长频道右边的<em class="f22px" style="font-weight:bold;">+</em></li>
		</ul>
		<? endif;?>
		<div class="smallCon">
			<div id="optionswindow" class="blackBox" style="display:none; margin-top:6px;">
            	<a href="javascript:void(0)" onclick="aj_hidedit_options();" class="close">关闭</a>
				<div class="listEditHot">
					<h3>添加新选项-> 站长频道右边的 <em style="font-size:16px;font-weight:bold;">+</em></h3>
					<p id="name_option" class="nameThis">命名此选项: <input type="text" name="opname" id="opname" value="<?=$currentoption['opname'];?>" onblur="aj_edit_option(<?=$opid;?>, this.value);" style="font-size:14px; margin-left:10px; margin-right:20px;" /> <a href="#TB_inline?height=120&width=396&inlineId=hiddenModalContent7&modal=true" class="cYellow thickbox">删除此选项</a></p>
					<p style="font-size:14px; padding-top:8px;">添加应用 <em id="plugins_msg" class="tips1">&nbsp;</em></p>
					<ul id="plugins">
					<? foreach($modules as $mod):?>
						<li>
							<div class="option_box_member_info">
								<div class="option_title"><?=$mod["name"];?></div>
								<div class="option_detail"><?=$mod["description"];?></div>
								<? if(in_array($mod["id"], array(1,3))):?>
								<div class="option_detail" style="color:#d0d1d2">(不支持公共创建)</div>
								<? endif;?>
							</div>
							<span class="listHotTxt"><input type="button" class="addKey" value="添加" onclick="aj_add_plugins(<?=$mod["id"];?>, '<?=$mod["name"];?>', <?=$opid;?>, '<?=c("site_url");?>', '<?=$site["domain"];?>');"><em id="plugins_msg_<?=$mod["id"];?>" class="t_box">&nbsp;</em></span>
						</li>
					<? endforeach;?>
					</ul>
					<div class="hackbox"></div>
				</div>
				<div class="blank8"></div>
			</div>
			<div class="column">
			<!-- 显示应用 -->
				<ul id="pluginsarea">
				<? foreach($oplugins as $opkey => $oplugin):?>
					<li id="plugin_<?=$oplugin["id"];?>">
						<h3><span class="f22px" id="pltitle_<?=$oplugin["id"];?>"><?=$oplugin["plname"];?>
						<? if($oplugin["public"] == '1' && !in_array($oplugin['moduleid'],array(1,3))):?>
						[公共]
						<? endif;?>
						</span>
						 <? if(in_array($oplugin['moduleid'], array(2,4,5,6,7,8))):?>
						 <a href="<?=c('site_url');?><?=$site['domain'];?>/plugin/list/<?=$oplugin["id"];?>">(全部)</a>
						 <? endif;?>
						 <? if($isowner || ($is_fansed && $oplugin["public"] == '1' && !in_array($oplugin['moduleid'],array(1,3)))):?>
						 <a href="<?=c('site_url');?><?=$site['domain'];?>/plugin/add/<?=$oplugin["id"];?>">(新建)</a>
						 <? endif;?>
						 <span class="setUp"><? if($isowner):?><a href="javascript:void(0)" onclick="aj_showedit_plugin(<?=$oplugin["id"];?>)">(设置)</a><? endif;?></span></h3>
					</li>
					<div id="plwindow_<?=$oplugin["id"];?>" class="applyBox">
						<label>命名此应用:</label>
						<input type="text" maxlength="10" name="plname_<?=$oplugin["id"];?>" id="plname_<?=$oplugin["id"];?>" value="<?=$oplugin["plname"];?>" class="inputTxt" />
						<input type="button" onclick="aj_edit_plugin(<?=$oplugin["id"];?>);"  class="smallKey" value="保存"> <input type="button" onclick="aj_hidedit_plugin(<?=$oplugin["id"];?>);" class="smallKey" value="取消">
						<span><a href="javascript:aj_del_plugin(<?=$oplugin["id"];?>);" onclick="return confirm('是否要删除？');" class="deleteBox">删除此应用</a></span>
						<div class="hackbox"></div>
						<? if($oplugin['moduleid'] != "3" && $oplugin['moduleid'] != "1"):?>
						<label><input type="checkbox" name="public_<?=$oplugin["id"];?>" id="public_<?=$oplugin["id"];?>" value="1" <? if($oplugin["public"] == '1'):?> checked <? endif;?>>公共创建(让粉丝参与本应用的内容创建)</label>
						<? endif;?>
					</div>
					
					<!-- 应用数据列表 -->
					<!-- 热点 -->
					<? if($oplugin['moduleid'] == "1" && !(count($oplugin["lists"][0])==0 && count($oplugin["lists"][1])==0 && count($oplugin["lists"][2])==0)):?>
					<div class="adFlashbox">
						<span class="tl"></span><span class="tr"></span>
						<div class="cc">
							<div class="ad300">
								<ul id="hotpics<?=$opkey;?>" style="position:relative;">
								<? 
									$start = 0;
									if(count($oplugin["lists"][0]) == 0){
										if(count($oplugin["lists"][1])>0) {
											$start = 1;
										} elseif(count($oplugin["lists"][2])>0) {
											$start = 2;
										}
									} 
								?>
								<? for($k = 0; $k<3; $k++):?>
									<? if(isset($oplugin["lists"][$k]) && count($oplugin["lists"][$k])>0):?>
									<? $lists = $oplugin["lists"][$k];?>
										<li style="display:block; width:300px; height:300px; overflow:hidden;position:absolute; <? if($k != $start):?> display:none <? endif;?> ">
										<img src="<?=$lists['firstpic'];?>" width="300" />
										</li>
									<? else:?>
										<li style="display:block; width:300px; height:300px;overflow:hidden;position:absolute;display:none">&nbsp;</li>
									<? endif;?>
								<? endfor;?>
								</ul>
							</div>
							<div class="adTab">
								<ul id="hotlist<?=$opkey;?>">
								<? for($k = 0; $k<3; $k++):?>
									<? if(isset($oplugin["lists"][$k]) && count($oplugin["lists"][$k])>0):?>
									<? $lists = $oplugin["lists"][$k];?>
										<li id="<?=$k+1;?>" <? if($k == $start):?>class="sel"<? endif;?>><span></span><p><a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>"><?=$lists['title'];?></a></p></li>
									<? else:?>
										<li id="<?=$k+1;?>"><span></span><p>&nbsp;</p></li>
									<? endif;?>
								<? endfor;?>	
								</ul>
							</div>
						</div>
						<span class="bl"></span><span class="br"></span>					
					</div>
					<script type="text/javascript">
					    var t<?=$opkey;?> = n<?=$opkey;?> = 0, count<?=$opkey;?>;
					    $(document).ready(function(){    
					        count<?=$opkey;?>=$("#hotpics<?=$opkey;?> li").length;  
					        /*$("#hotpics<?=$opkey;?> li:not(:first-child)").hide();*/
					        $("#hotlist<?=$opkey;?> li").mouseover(function() {
					            var i = $(this).attr('id') - 1;
					            n<?=$opkey;?> = i;
					            if (i >= count<?=$opkey;?>) return;
					            $("#hotpics<?=$opkey;?> li").filter(":visible").hide().parent().children().eq(i).show();
					            $(this).addClass('sel').siblings().removeClass('sel');
					        });
					        t<?=$opkey;?> = setInterval("showAuto<?=$opkey;?>()", 5000);
					        $("#hotpics<?=$opkey;?> li").hover(function(){clearInterval(t<?=$opkey;?>)}, function(){t<?=$opkey;?> = setInterval("showAuto<?=$opkey;?>()", 5000);});
					    })
					    
					    function showAuto<?=$opkey;?>()
					    {
					        n<?=$opkey;?> = n<?=$opkey;?> >=(count<?=$opkey;?> - 1) ? 0 : ++n<?=$opkey;?>;
					        $("#hotlist<?=$opkey;?> li").eq(n<?=$opkey;?>).trigger('mouseover');
					    }
					</script>
					
					<!-- 资讯 -->
					<? elseif ($oplugin['moduleid'] == "2" && isset($oplugin["lists"][0]) && count($oplugin["lists"][0])>0):?>
					<? foreach($oplugin["lists"] as $k => $lists):?>
	                <div class="column">
					<p class="title"><a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>"><?=$lists['title'];?></a> <?php if($oplugin["public"] == '1' && $lists["userid"] != $owner['id']):?><img src="/images/gong.gif" style="vertical-align:sub;" title="来自公共创建" /><? endif;?></p>
					<div class="time"><?=date("Y-m-d H:i", $lists['addtime']);?></div>
	                 <div class="left" style="padding-right:12px">
						<? if($lists['firstpic'] != ""):?>
							<img src="<?=$lists['firstpic'];?>" width="120" height="160" alt="<?=$lists['title'];?>" />
						<? endif;?>
					 </div>   
					 <div class="rightBox">
	                        <?=msubstr(strip_tags($lists['description']), 0, 300,"utf-8","<em class='DpGray'>...</em>");?>
	                        <em class="cCGray">(<?=$lists['commentcount'];?>回应)</em>
	                 </div>
	                 </div>
	                 <div class="blank8"></div>
	                 <? endforeach;?>
	                 
	                 <!-- 公告 -->
					 <? elseif ($oplugin['moduleid'] == "3" && isset($oplugin["lists"]) && count($oplugin["lists"])>0):?>
	                 	<div class="grayBox">
							<?=nl2br(strip_tags($oplugin['lists']['description'], '<a>'));?>
						</div>
						
					 <!-- 活动 -->
					 <? elseif ($oplugin['moduleid'] == "4" && isset($oplugin["lists"]) && count($oplugin["lists"])>0):?>
						<? foreach($oplugin["lists"] as $k => $lists):?>
	                 	<p class="title"><a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>"><?=$lists["title"];?></a> <?php if($oplugin["public"] == '1' && $lists["userid"] != $owner['id']):?><img src="/images/gong.gif" style="vertical-align:sub;" title="来自公共创建" /><? endif;?></p>
						<ul class="f14px">
							<li>日期: <?=date("Y-m-d",$lists["startdate"]);?> 至 <?=date("Y-m-d",$lists["enddate"]);?></li>
							<li>时间: <?=$lists["godate"];?></li>
							<li>地点: <?=$lists["address"];?></li>
							<li><em class="cCGray"><?=$lists["interests"];?>人感兴趣</em><em class="cCGray"><em style="margin-left:12px" class="cCGray"><?=$lists["joins"];?>人要参加</em></em></li>
						</ul>
						<div class="blank8"></div>
						<? endforeach;?>
						
						<!-- 投票 -->
						<? elseif ($oplugin['moduleid'] == "5" && isset($oplugin["lists"]) && count($oplugin["lists"])>0):?>
						<? foreach($oplugin["lists"] as $key => $lists):?>
	                 	<p class="title"><a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>"><?=$lists["title"];?></a> <?php if($oplugin["public"] == '1' && $lists["userid"] != $owner['id']):?><img src="/images/gong.gif" style="vertical-align:sub;" title="来自公共创建" /><? endif;?></p>
	                 	<? if(!$lists['isposted']):?>
							<form action="<?=c('site_url');?><?=$site['domain'];?>/vote" method="post" enctype="multipart/form-data" onsubmit="return Validator.Validate(this,3);">
	                 		<ul class="f14px">
								<li>(<?=$lists["type"];?>)</li>
								<? foreach ($lists["options"] as $k => $option):?>
								<? if($lists["typeid"] == 0):?>
									<? $boxname = "option_".$lists["id"];?>
								<? else:?>
									<? $boxname = "option_".$lists["id"]."[]";?>
								<? endif;?>
								<li><input name="<?=$boxname;?>" id="<?=$boxname;?>" type="<?=$lists["box"];?>" value="<?=$option["id"];?>" <? if($k == 0):?>dataType="Group" msg="至少选择一个选项"<? endif;?> /><?=$option["option"];?></li>
								<? endforeach;?>
							</ul>
							
							<input type="hidden" name="moduleid" id="moduleid" value="<?=$lists['moduleid'];?>">
							<input type="hidden" name="dataid" id="dataid" value="<?=$lists['id'];?>">
							<input type="hidden" name="typeid" id="typeid" value="<?=$lists['typeid'];?>">
							<p style="height:30px;padding-top:12px"><? if($account):?><input name="dosubmit" id="dosubmit" value="投票" type="submit" class="airIco" /><? else:?><a href="#TB_inline?height=120&width=396&inlineId=hiddenModalContent&modal=true" class="thickbox"><input name="dosubmit" id="dosubmit" value="投票" type="button" class="airIco" style="border:0;" /></a><? endif;?> <em class="cCGray"><?=$lists["total"];?>投票</em> <em class="cCGray"><?=$lists['commentcount'];?>回应</em></p>
							</form>
						<? else:?>
						<ul class="f14px">
						<? foreach ($lists['optionsdata'] as  $val):?>
							<li><span class="countTit"><?=$val["option"];?></span><span class="countBox"><span class="percent" style="width:<?=$val["scale"];?>%"></span></span><span class="countRight"><?=$val["scale"];?>%(<?=$val["count"];?>)</span></li>
						<? endforeach;?>
						</ul>
						<div class="hackbox"></div>
						<p class="f14px" style="padding-top:12px;"><em class="cGreen">已投过</em> <em class="cCGray"><?=$lists["total"];?>投票</em> <em class="cCGray"><?=$lists['commentcount'];?>回应</em></p>
						<? endif;?>
						<div class="blank8"></div>
						<? endforeach;?>
						
						<!-- 专题 -->
						<? elseif ($oplugin['moduleid'] == "6" && isset($oplugin["lists"]) && count($oplugin["lists"])>0):?>
						<div style="margin-top:12px;"></div>
						<? foreach($oplugin["lists"] as $k => $lists):?>
						<div class="w430">
						<p class="tit"><a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>"><?=$lists["title"];?></a> <?php if($oplugin["public"] == '1' && $lists["userid"] != $owner['id']):?><img src="/images/gong.gif" style="vertical-align:sub;" title="来自公共创建" /><? endif;?></p>
						<ul class="f14px">
							<?=msubstr(strip_tags($lists["description"]),0,150);?>							
						</ul>
						</div>
						<div class="right">
						<? if($lists["pic"] && $lists["pic"] != ""):?>
							<img src="<?=gurl('data');?>/upload_pic/<?=$lists["pic"];?>" alt="<?=$lists["title"];?>" width="200" height="150" />
						<? endif;?>
						</div>
						<div class="blank8" style="height:20px;"></div>
						<? endforeach;?>
					
						<!-- 视频 -->
						<? elseif ($oplugin['moduleid'] == "7" && isset($oplugin["lists"]) && count($oplugin["lists"])>0):?>
						<ul class="listCam">
						<? foreach($oplugin["lists"] as $k => $lists):?>
						<li>
							<a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>"><img src="<? if($lists["pic"] == ''):?><?=gurl('images');?>/listCam.gif<? else:?><?=$lists["pic"];?><? endif;?>" onerror="this.src='<?=gurl('images');?>/listCam.gif';" width="150" height="114"/></a>
							<p class="f14px"><a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>" title="<?=$lists["title"];?>"><?=msubstr($lists["title"], 0, 8);?></a> <?php if($oplugin["public"] == '1' && $lists["userid"] != $owner['id']):?><img src="/images/gong.gif" style="vertical-align:sub;" title="来自公共创建" /><? endif;?></p>
							<p class="time"><?=date("Y-m-d H:i", $lists["addtime"]);?></p>
							<p class="cDGray"><?=$lists["commentcount"];?>回应</p>
						</li>
						<? endforeach;?>
						</ul>
						<div class="blank8"></div>
						
						<!-- 相册 -->
						<? elseif ($oplugin['moduleid'] == "8" && isset($oplugin["lists"]) && count($oplugin["lists"])>0):?>
						<ul class="listImgall">
						<? foreach($oplugin["lists"] as $k => $lists):?>
						<li style="width:120px;height:90px;overflow:hidden;">
							<a href="<?=c('site_url');?><?=$site['domain'];?>/show/<?=$lists["moduleid"];?>/<?=$lists["id"];?>"><img src="<?=gurl('data');?>/upload_pic/<?=$lists["pic"];?>" alt="图片" width="120" /></a>
						</li>
						<? endforeach;?>
						</ul>
						
					<? endif;?>
					<div id="blank_<?=$oplugin["id"];?>" class="blank18"></div>
				<? endforeach;?>
				</ul>
			</div>		
			<div class="blank8"></div>
			</div>
	</div>
	
	<script language="javascript" src="<?=c('site_url');?><?=$site['domain'];?>/right"></script>
	<div class="hackbox"></div>
</div>
